{% extends 'index.html' %}
{% load static %}
{% block mycss %}
    <script type="text/javascript" src="{% static 'js/echarts/echarts.js' %}"></script>
    <script src="{% static 'js/jquery.min.js' %}"></script>
    <script src="{% static 'fishbone/html2canvas.js' %}"></script>
    <script src="{% static 'fishbone/fishBone2.js' %}"></script>
    <link rel="stylesheet" href="{% static 'fishbone/fishBone2.css' %}">
    <link href="{% static 'js/lib/layui/css/layui.css' %}" rel="stylesheet">
    <style>
        {#    修改tab切换页选中的颜色#}
        .nav-tabs.nav > li > a:hover, .nav-tabs.nav > li > a:focus {
            border-bottom: 1px solid #042c70;

        }

        .nav-tabs > li.active > a, .nav-tabs > li.active > a:focus, .nav-tabs > li.active > a:hover {
            border-bottom: 1px solid #042c70;

        }
    </style>
{% endblock %}
{% block title %}
    <span class="navbar-page-title">军事需求业务模型构建 - 数据推理分析模型构建</span>
{% endblock %}
{% block content %}
    <div class='container-fluid'>
        <button class="my-btn" style="margin-left: 10px;float: left" onclick="add_base_model()"> 创建基础模型</button>
        <div class="form-group" style="margin: 50px 10px;padding: 10px; background-color: #ffffff">
            <!-- 页面信息展示 -->
            <table class="my-table" style="width: 100%">
                <thead>
                <tr>
                    <th style="text-align: center;">序号</th>
                    <th style="text-align: center;">模型名称</th>
                    <th style="text-align: center;">模型类型</th>
                    <th style="text-align: center;">模型操作</th>
                </tr>
                </thead>

                <tbody>
                {% for single_data in base_model_obj %}
                    <tr style="text-align: center">
                        <td>{{ forloop.counter }}</td>
                        <td>{{ single_data.name }}</td>
                        <td>{{ single_data.type }}</td>
                        <td>
                            <button class="my-btn" id="base_model_edit" onclick="base_model_edit({{ single_data.id }})"> 编辑</button>
                            <button class="my-btn" onclick="model_del({{ single_data.id }})">删除</button>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>

            </table>
        </div>
    </div>
{% endblock %}

{% block myjs %}
    <script src="{% static 'js/lib/layui/layui.js' %}"></script>
    <script>
        // 左侧菜单栏固定
        document.getElementById("jsxqywmxgj").style.display = 'block';
        document.getElementById("sjtlfxmxgj").style.backgroundColor = 'rgba(30,21,21,0.44)';

        // 创建基础模型
        function add_base_model() {
            layui.use(['layer', 'form'], function () {
                var layer = layui.layer,
                    form = layui.form;
                layer.open({
                    type: 2,
                    anim: 2,//弹出方式
                    shade: 0.3, //遮罩透明度
                    maxmin: true, //允许全屏最小化
                    shadeClose: true,//点击外部不关闭
                    area: ['800px', '400px'],
                    title: '基础模型创建',  //题目
                    content: "{% url 'add_base_model' %}"
                });
            })
        }

        // 基础模型编辑
        function base_model_edit(model_id) {
            layui.use(['layer', 'form'], function () {
                var layer = layui.layer,
                    form = layui.form;
                layer.open({
                    type: 2,
                    anim: 2,//弹出方式
                    shade: 0.3, //遮罩透明度
                    maxmin: true, //允许全屏最小化
                    shadeClose: true,//点击外部不关闭
                    area: ['800px', '325px'],
                    title: '基础模型编辑',  //题目
                    content: "{% url 'edit_base_model' %}?model_id=" + model_id
                });
            })
        }

        /**
         * 删除数据
         */
        function model_del(id) {
            // 生成路径
            var url = "{% url 'delete_base_model' 0  %}";
            url = url.replace(/0/, id);
            // 确认框
            zdconfirm('系统确认框', '你确认删除该条数据吗？', r => r ? window.location.href = url : '');
        }
    </script>
{% endblock %}



